$(document).ready(function () {
  var table = $('table#table').DataTable({
    ajax: {
      url: baseUrl + '/datatable',
      data : function(d) {
              d.docnumber = docnumber;
		      return d;
      }
    },
    searchCols: [{
        search: docnumber
      }],
    order: [
      [1, 'asc']
    ],
    columns: [{
    	data: 'documentNumber',
    	data: 'documentNumber',
    	defaultContent: '',
		visible: false
    },{
      data: 'id',
      sortable: false,
      defaultContent: '',
      'class': 'text-center',
      render: function (data, type, row, meta) {
        return '<div class="checkbox"><input type="checkbox" name="ids" value="' + data + '"/><label for="ids"/></div>'
      }
     },{
      name: 'documentNumber',
      data: 'documentNumber'
    },{
      name: 'documentLinenumber',
      data: 'documentLinenumber'
    },{
      name: 'materialCode',
      data: 'materialCode'
    },{
      name: 'materialName',
      data: 'materialName'
    },{
      name: 'orderedQty',
      data: 'orderedQty'
    },{
        name: 'sortationLocName',
        data: 'sortationLocName'
    },{
        name: 'lineCode',
        data: 'lineCode'
    },{
        name: 'uloc',
        data: 'uloc'
    },{
        name: 'docWbsNum',
        data: 'docWbsNum'
    },{
        name: 'containerNumber',
        data: 'containerNumber'
    },{
        name: 'deliveryTime',
        data: 'deliveryTime'
    }]
  });

  table.on('click', '.del', function () {
    var id = table.row($(this).parents('tr')).data().id;
    $("#delForm #ids").val(id);
    if (id) {
      bootbox.confirm("确定要删除数据吗?", function (result) {
        if (result) {
          $("#delForm").submit();
        }
      });
    }
  });

  $('.search-form').on("submit", function (e) {
    table.draw();
    //阻止表单submit
    return false;
  });

});
